#pragma once

#include<threads.h>
#include<string>
#include<sys/types.h>

typedef void*(*fun_t)(void*);

struct ThreadData
{
    void *args_;
    std::string name_;
};

class Thread
{
public:
    Thread(int num, fun_t callback, void* args):callback_(callback)
    {
        char Buffer[64];
        snprintf(Buffer, sizeof(Buffer), "Thread - %d", num);
        name_ = Buffer;

        tdata_.args_ = args;
        tdata_.name_ = name_;
    }

    void Start()
    {
        pthread_create(&td_, nullptr, callback_, (void*)&tdata_);
    }

    void join()
    {
        pthread_join(td_, nullptr);
    }
    std::string name()
    {
        return name_;
    }
    ~Thread()
    {
    }

private:
    std::string name_;
    fun_t callback_;
    ThreadData tdata_;
    pthread_t td_;
};